package com.lz.message.redis;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class MessageService {
	
	@Resource
	private StringRedisTemplate stringRedisTemplate;
	
    @Value("${redis.msg.zset}")
    private String redisTopic;
	
    /**
     * 新增一条消息，放入有序集合
     * @param delayTime 延迟时间
     * @param msg 消息内容
     */
	public void createMsg(long delayTime, String msg) {
		stringRedisTemplate.opsForZSet().add(redisTopic, msg, delayTime);
	}

}
